package Work;

import java.util.ArrayList;

public class TestHero {
    public static void main(String[] args) {

        Hero h1 = new Hero(1, "亚索", "男");
        Hero h2 = new Hero(2, "劫", "男");
        Hero h3 = new Hero(3, "xxxxx", "女");
        Hero h4 = new Hero(4, "xxxxx", "男");
        Hero h5 = new Hero(5, "xxxxx", "男");
        ArrayList<Hero> list = new ArrayList<>();
        list.add(h1);
        list.add(h2);
        list.add(h3);
        list.add(h4);
        list.add(h5);

        for (int i = 0; i < list.size(); i++) {
            Hero hero = list.get(i);
            String name = hero.getName();
            String sex = hero.getSex();
            if ("男".equals(sex)&&name.length()>=3){
                 list.remove(i);
                i--;
            }

        }
        for (int i = 0; i < list.size(); i++) {
            Hero hero = list.get(i);
           hero.show();
        }
    }
}
